home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / util1 / shdwst13.lha / ShadowStart13 / 3.1 / ShadowStart.c < prev   
C/C++ Source or Header  |  1995-08-15  |  6KB  |  153 lines

  1. /* $Revision Header built automatically *************** (do not edit) ************
  2. **
  3. ** © Copyright by Lars Eilebrecht (Shadowfox)
  4. **
  5. ** File             : Work:Program/SC/PRG/ShadowStart/ShadowStart.c
  6. ** Created on       : Mittwoch, 16.11.94 17:23:09
  7. ** Created by       : Lars Eilebrecht
  8. ** Current revision : V1.3
  9. **
  10. **
  11. ** Purpose
  12. ** -------
  13. **     Disable "WBStartup" and/or "User-Startup" during startup. (V40)
  14. **
  15. ** Revision V1.3
  16. ** --------------
  17. ** created on Montag, 14.08.95 22:41:18  by  Lars Eilebrecht.   LogMessage :
  18. **   - added validation test for SYS: partition
  19. **     minor code changes
  20. **
  21. ** Revision V1.2
  22. ** --------------
  23. ** created on Freitag, 09.12.94 01:06:44  by  Lars Eilebrecht.   LogMessage :
  24. **   - minor code changes
  25. **
  26. ** Revision V1.1
  27. ** --------------
  28. ** created on Montag, 28.11.94 18:58:55  by  Lars Eilebrecht.   LogMessage :
  29. **  -*-  changed on Samstag, 03.12.94 22:12:20  by  Lars Eilebrecht.   LogMessage :
  30. **   - recompiled ShadowStart without startup-code
  31. **     (results in a shorter executable)
  32. **  -*-  created on Montag, 28.11.94 18:58:55  by  Lars Eilebrecht.   LogMessage :
  33. **   - added NewShell-button
  34. **     renamed other buttons, so that it fit on a lores-screen
  35. **     removed stdio.h include (shorter executable)
  36. **     cleaned up code a little
  37. **
  38. ** Revision V1.0
  39. ** --------------
  40. ** created on Mittwoch, 16.11.94 17:23:09  by  Lars Eilebrecht.   LogMessage :
  41. **     --- Initial release ---
  42. **
  43. *********************************************************************************/
  44. #define REVISION "1.3"
  45. #define REVDATE  "14.08.95"
  46. #define REVTIME  "22:41:18"
  47. #define AUTHOR   "Lars Eilebrecht"
  48. #define VERNUM   1
  49. #define REVNUM   3
  50. #define TITLE "ShadowStart "REVISION" ("REVDATE") (V40) © by "AUTHOR
  51.  
  52. #include <exec/types.h>
  53. #include <intuition/intuition.h>
  54. #include <libraries/lowlevel.h>
  55. #include <libraries/dos.h>
  56.  
  57. #include <pragmas/exec_pragmas.h>
  58. #include <pragmas/dos_pragmas.h>
  59. #include <pragmas/intuition_pragmas.h>
  60. #include <pragmas/lowlevel_pragmas.h>
  61.  
  62. #include <clib/exec_protos.h>
  63. #include <clib/dos_protos.h>
  64. #include <clib/intuition_protos.h>
  65. #include <clib/lowlevel_protos.h>
  66.  
  67. static const char ver[]="$VER: "TITLE"\0";
  68.  
  69. int ShadowStart(void)
  70. {
  71.   LONG rc=RETURN_FAIL;
  72.  
  73.   struct Library *DOSBase;
  74.  
  75.   if(DOSBase=OpenLibrary("dos.library",37))
  76.   {
  77.     struct Library *LowLevelBase;
  78.  
  79.     if(LowLevelBase=OpenLibrary("lowlevel.library",40))
  80.     {
  81.       struct Library *IntuitionBase;   
  82.  
  83.       if(IntuitionBase=OpenLibrary("intuition.library",37))
  84.       {
  85.         BPTR syslock=Lock("SYS:",ACCESS_READ);                  // get lock on SYS: partition
  86.  
  87.         rc=RETURN_OK;                                           // so far it's ok...
  88.         if(syslock)                                             // Got a lock? Exit, if not...
  89.         {
  90.           struct KeyQuery spacebar =                            // declare KeyQuery-struct
  91.                           {
  92.                             (UWORD)64,                          // rawkeycode for spacebar
  93.                             FALSE,                              // not pressed yet...
  94.                           };
  95.           struct InfoData id;
  96.           BOOL success=success=Info(syslock,&id);               // get info on SYS:
  97.           while(success&&(id.id_DiskState==ID_VALIDATING))
  98.           {                                                     // delay program excution until SYS: is validated
  99.             Delay(150);                                         // wait 3 seconds...
  100.             success=Info(syslock,&id);                          // and check again
  101.           }                            
  102.           if(!success)
  103.             rc=RETURN_FAIL;
  104.           if(Rename("SYS:_WBStartup","SYS:WBStartup"))          // rename to original names
  105.             Rename("SYS:_WBStartup.info","SYS:WBStartup.info");
  106.           Rename("SYS:S/_User-Startup","SYS:S/User-Startup");
  107.           QueryKeys(&spacebar,(UBYTE)1);                        // dirty spacebar check ;-)
  108.           if(spacebar.kq_Pressed)                               // Was it pressed? Silent exit, if not...
  109.           {
  110.             LONG result;
  111.  
  112.             struct EasyStruct shadowES =                        // declare EasyRequest-struct
  113.                               {
  114.                                 sizeof(struct EasyStruct),
  115.                                 0, // no flags
  116.                                 "ShadowStart "REVISION" ("REVDATE") © by Lars `SFX' Eilebrecht",
  117.                                 "\nSelect startup-items you want to disable\n\nor select `NewShell' to open a shell-window\n",
  118.                                 "WB + User|WB|User|NewShell|Cancel",
  119.                               };
  120.  
  121.             result=EasyRequest(NULL,&shadowES,NULL);
  122.             switch (result)
  123.             {                                                   // note: success of rename-operation isn't checked...
  124.               case 1: 
  125.                 Rename("SYS:S/User-Startup","SYS:S/_User-Startup");
  126.               case 2:
  127.                 Rename("SYS:WBStartup","SYS:_WBStartup");
  128.                 Rename("SYS:WBStartup.info","SYS:_WBStartup.info");
  129.                 break;
  130.               case 3:
  131.                 Rename("SYS:S/User-Startup","SYS:S/_User-Startup");
  132.                 break;
  133.               case 4:
  134.                 if(!Execute("NewShell",0,0))                    // open a shell-window...
  135.                   rc=RETURN_FAIL;
  136.                 Wait(SIGBREAKF_CTRL_C);                         // 'hold' startup-sequence...
  137.             }
  138.           }
  139.           UnLock(syslock);
  140.         }
  141.         CloseLibrary(IntuitionBase);
  142.       }
  143.       else
  144.         PrintFault(ERROR_INVALID_RESIDENT_LIBRARY,"intuition.library");
  145.       CloseLibrary(LowLevelBase);
  146.     }
  147.     else
  148.       PrintFault(ERROR_INVALID_RESIDENT_LIBRARY,"lowlevel.library");
  149.     CloseLibrary(DOSBase);
  150.   }
  151.   return(rc);
  152. }
  153.